home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Borland / Borland C++ V5.02 / CTRLBA.PAK / PALETTE.CPP < prev    next >
C/C++ Source or Header  |  1997-05-06  |  2KB  |  85 lines

  1. // palette.cpp : implementation of the Floating tool palette class
  2. //
  3. // This is a part of the Microsoft Foundation Classes C++ library.
  4. // Copyright (C) 1992-1995 Microsoft Corporation
  5. // All rights reserved.
  6. //
  7. // This source code is only intended as a supplement to the
  8. // Microsoft Foundation Classes Reference and related
  9. // electronic documentation provided with the library.
  10. // See these sources for detailed information regarding the
  11. // Microsoft Foundation Classes product.
  12.  
  13. #include "stdafx.h"
  14. #include "ctrlbars.h"
  15.  
  16. #include "palette.h"
  17.  
  18. #ifdef _DEBUG
  19. #undef THIS_FILE
  20. static char BASED_CODE THIS_FILE[] = __FILE__;
  21. #endif
  22.  
  23. /////////////////////////////////////////////////////////////////////////////
  24. // CPaletteBar
  25.  
  26. BEGIN_MESSAGE_MAP(CPaletteBar, CToolBar)
  27.     //{{AFX_MSG_MAP(CPaletteBar)
  28.     //}}AFX_MSG_MAP
  29. END_MESSAGE_MAP()
  30.  
  31. /////////////////////////////////////////////////////////////////////////////
  32. // CPaletteBar construction/destruction
  33.  
  34. CPaletteBar::CPaletteBar()
  35. {
  36.     m_nColumns = 2;
  37.     m_cxLeftBorder = 5;
  38.     m_cyTopBorder = 5;
  39.     m_cxRightBorder = 5;
  40.     m_cyBottomBorder = 5;
  41. }
  42.  
  43. CPaletteBar::~CPaletteBar()
  44. {
  45. }
  46.  
  47. /////////////////////////////////////////////////////////////////////////////
  48. // CPaletteBar diagnostics
  49.  
  50. #ifdef _DEBUG
  51. void CPaletteBar::AssertValid() const
  52. {
  53.     CToolBar::AssertValid();
  54. }
  55.  
  56. void CPaletteBar::Dump(CDumpContext& dc) const
  57. {
  58.     CToolBar::Dump(dc);
  59. }
  60.  
  61. #endif //_DEBUG
  62.  
  63. /////////////////////////////////////////////////////////////////////////////
  64. // CPaletteBar message handlers
  65.  
  66. void CPaletteBar::SetColumns(UINT nColumns)
  67. {
  68.     m_nColumns = nColumns;
  69.     int nCount = GetToolBarCtrl().GetButtonCount();
  70.  
  71.     for (int i = 0; i < nCount; i++)
  72.     {
  73.         UINT nStyle = GetButtonStyle(i);
  74.         BOOL bWrap = (((i + 1) % nColumns) == 0);
  75.         if (bWrap)
  76.             nStyle |= TBBS_WRAPPED;
  77.         else
  78.             nStyle &= ~TBBS_WRAPPED;
  79.         SetButtonStyle(i, nStyle);
  80.     }
  81.     
  82.     Invalidate();
  83.     GetParentFrame()->RecalcLayout();
  84. }
  85.